<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Retrieves a list of foreign keys</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.odbc-field-type.html">« odbc_field_type</a></li>
      <li style="float: right;"><a href="function.odbc-free-result.html">odbc_free_result »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.uodbc.html">ODBC 函数</a></li>
    <li>Retrieves a list of foreign keys</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.odbc-foreignkeys" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">odbc_foreignkeys</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">odbc_foreignkeys</span> &mdash; <span class="dc-title">Retrieves a list of foreign keys</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.odbc-foreignkeys-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>odbc_foreignkeys</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">resource</span> <code class="parameter">$odbc</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$pk_catalog</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$pk_schema</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$pk_table</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$fk_catalog</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$fk_schema</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$fk_table</code></span><br>): <span class="type"><span class="type">resource</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Retrieves a list of foreign keys in the specified table or a list of
   foreign keys in other tables that refer to the primary key in the
   specified table
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.odbc-foreignkeys-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">odbc</code></dt>

     <dd>

      <p class="para">ODBC 连接标识符，详见
<span class="function"><a href="function.odbc-connect.html" class="function">odbc_connect()</a></span>。</p>
     </dd>

    
    
     <dt>
<code class="parameter">pk_catalog</code></dt>

     <dd>

      <p class="para">
       The catalog (&#039;qualifier&#039; in ODBC 2 parlance) of the primary key table.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">pk_schema</code></dt>

     <dd>

      <p class="para">
       The schema (&#039;owner&#039; in ODBC 2 parlance) of the primary key table.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">pk_table</code></dt>

     <dd>

      <p class="para">
       The primary key table.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">fk_catalog</code></dt>

     <dd>

      <p class="para">
       The catalog (&#039;qualifier&#039; in ODBC 2 parlance) of the foreign key table.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">fk_schema</code></dt>

     <dd>

      <p class="para">
       The schema (&#039;owner&#039; in ODBC 2 parlance) of the foreign key table.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">fk_table</code></dt>

     <dd>

      <p class="para">
       The foreign key table.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.odbc-foreignkeys-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an ODBC result identifier 或者在失败时返回 <strong><code>false</code></strong>.
  </p>
  <p class="para">
   The result set has the following columns:
   <ul class="itemizedlist">
    <li class="listitem"><span class="simpara"><code class="literal">PKTABLE_CAT</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">PKTABLE_SCHEM</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">PKTABLE_NAME</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">PKCOLUMN_NAME</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">FKTABLE_CAT</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">FKTABLE_SCHEM</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">FKTABLE_NAME</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">FKCOLUMN_NAME</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">KEY_SEQ</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">UPDATE_RULE</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">DELETE_RULE</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">FK_NAME</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">PK_NAME</code></span></li>
    <li class="listitem"><span class="simpara"><code class="literal">DEFERRABILITY</code></span></li>
   </ul>
   Drivers can report additional columns.
  </p>
  <p class="simpara">
   If the foreign keys associated with a primary key are requested, the result set
   is ordered by <code class="literal">FKTABLE_CAT</code>, <code class="literal">FKTABLE_SCHEM</code>,
   <code class="literal">FKTABLE_NAME</code> and <code class="literal">KEY_SEQ</code>.
   If the primary keys associated with a foreign key are requested, the result set
   is ordered by <code class="literal">PKTABLE_CAT</code>, <code class="literal">PKTABLE_SCHEM</code>,
   <code class="literal">PKTABLE_NAME</code> and <code class="literal">KEY_SEQ</code>.
  </p>
  <p class="simpara">
   If <code class="parameter">pk_table</code> contains a table name,
   <span class="function"><strong>odbc_foreignkeys()</strong></span> returns a result set
   containing the primary key of the specified table and all of the
   foreign keys that refer to it.
  </p>
  <p class="simpara">
   If <code class="parameter">fk_table</code> contains a table name,
   <span class="function"><strong>odbc_foreignkeys()</strong></span> returns a result set
   containing all of the foreign keys in the specified table and the
   primary keys (in other tables) to which they refer.
  </p>
  <p class="simpara">
   If both <code class="parameter">pk_table</code> and
   <code class="parameter">fk_table</code> contain table names,
   <span class="function"><strong>odbc_foreignkeys()</strong></span> returns the foreign keys in
   the table specified in <code class="parameter">fk_table</code> that refer
   to the primary key of the table specified in
   <code class="parameter">pk_table</code>. This should be one key at most.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.odbc-foreignkeys-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.odbc-tables.html" class="function" rel="rdfs-seeAlso">odbc_tables()</a> - Get the list of table names stored in a specific data source</span></li>
    <li class="member"><span class="function"><a href="function.odbc-primarykeys.html" class="function" rel="rdfs-seeAlso">odbc_primarykeys()</a> - Gets the primary keys for a table</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>